package shuaige.jdk.多线程.base.线程类方法使用示例;

public class 基本方法 implements Runnable {

    public static void main(String[] args) {
        常用get方法();
    }

    /**
     * 常用方法
     */
    public static void 常用get方法() {
        Thread thread = Thread.currentThread();
        System.out.println("返回当前正在执行的线程对象的引用：" + thread);
        String name = thread.getName();
        System.out.println("获取当前线程的名称：" + name);
        long id = thread.getId();
        System.out.println("获取当前线程的id：" + id);
        ThreadGroup threadGroup = thread.getThreadGroup();
        System.out.println("获取当前线程组：" + threadGroup);
        int priority = thread.getPriority();
        System.out.println("返回此线程的优先级：" + priority);
        Thread.State state = thread.getState();
        System.out.println("返回此线程的优先级：" + state);
        ClassLoader contextClassLoader = thread.getContextClassLoader();
        System.out.println("返回此线程的上下文类加载器：" + contextClassLoader);
        StackTraceElement[] stackTrace = thread.getStackTrace();
        System.out.println("返回表示此线程的堆栈转储的堆栈跟踪元素数组：" + stackTrace);
        Thread.UncaughtExceptionHandler uncaughtExceptionHandler = thread.getUncaughtExceptionHandler();
        System.out.println("返回此线程由于未捕获的异常而突然终止时调用的处理程序：" + uncaughtExceptionHandler);
    }

    @Override
    public void run() {
        System.out.println("This is run() method");
    }
}